﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BoKeYuanApp.View;
using LiveCharts;
using LiveCharts.Wpf;

namespace BoKeYuanApp
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public SeriesCollection BlogeriesCollection { get; set; }

        /// <summary>
        /// 随笔
        /// </summary>
        public SeriesCollection JottingeriesCollection { get; set; }
        public SeriesCollection ArticleSeriesCollection { get; set; }
        public SeriesCollection CommentsSeriesCollection { get; set; }
        public MainWindow()
        {
            InitializeComponent();

            List<int> blogs = new List<int>();
            List<int> jottings = new List<int>();
            List<int> articles = new List<int>();
            List<int> comments = new List<int>();

            using (BoKeYuanDbEntities dbEntities = new BoKeYuanDbEntities())
            {
                foreach (Statistics statistics in dbEntities.Statistics.OrderBy(i => i.recordTime))
                {
                    blogs.Add(statistics.blog.Value);
                    jottings.Add(statistics.jotting.Value);
                    articles.Add(statistics.article.Value);
                    comments.Add(statistics.comment.Value);
                }
            }
            

            BlogeriesCollection = new SeriesCollection
            {

                new LineSeries
                {
                    Values = new ChartValues<int>(blogs)
                }
            };
            JottingeriesCollection = new SeriesCollection
            {
              
                new ColumnSeries
                {
                    Values = new ChartValues<int>( articles)

                },
                
            };
            
            ArticleSeriesCollection = new SeriesCollection
            {
               
                new StepLineSeries
                {
                    Values = new ChartValues<int>(jottings)
                }
            };

            CommentsSeriesCollection = new SeriesCollection
            {

                new LineSeries
                {
                    Values = new ChartValues<int>(comments)
                }
            };

           
            this.DataContext = this;
        }

        private void ShowMyRecordButton_OnClick(object sender, RoutedEventArgs e)
        {
            MyRecordView myRecordView = new MyRecordView();
            myRecordView.Owner = this;
            myRecordView.Show();
        }

        private void AppStatsEntryRecordButton_OnClick(object sender, RoutedEventArgs e)
        {
            AppStatsEntryView appStatsEntryView = new AppStatsEntryView();
            appStatsEntryView.Owner = this;
            appStatsEntryView.Show();
        }

        private void MyRecordEntryButton_OnClick(object sender, RoutedEventArgs e)
        {
            PersonStatsEntryView personStatsEntryView = new PersonStatsEntryView();
            personStatsEntryView.Owner = this;
            personStatsEntryView.Show();
        }
    }
}
